package com.juli.school.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @Description: 登录拦截器
 * @ClassName: LoginInterceptor
 * @author gaoxiang
 * @date 2014-12-3 下午3:04:03
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(LoginInterceptor.class);
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		HandlerMethod handler2 = (HandlerMethod) handler;
//		String user = handler2.getMethodAnnotation(String.class);
//		if (null == user) {
//			return true;
//		}
		HttpSession session = request.getSession();
		if (session.getAttribute("EnterpriseAgent") == null) {
			LOGGER.info("登录信息已过期，请重新登录");
			response.sendRedirect("/enterprise");
		}
		return false;
	}
}
